from backend.decoraters import pass_safe_method
from backend.permissions import PerformActionPermission


class GlobalNoitcePermission(PerformActionPermission):
    @pass_safe_method
    def has_object_permission(self, request, view, obj):
        if request.user.is_superuser:
            return True
        return False

    @pass_safe_method
    def has_permission(self, request, view):
        if request.user.is_superuser:
            return True
        return False


class NoticePermission(PerformActionPermission):
    @pass_safe_method
    def has_object_permission(self, request, view, obj):
        if request.user.id == object.recipient_id:
            return True
        return False

    @pass_safe_method
    def has_permission(self, request, view):
        if request.user.id == object.recipient_id:
            return True
        return False
